#ver 1.4 2009-05-27

import sys
sys.path.append("E:\\document\\TOOLs\\python\\dff2gulp\\")

from ppf2lib import ppf2lib
from msd2gin import msd2gin
from outcontrol import outcontrol

def usage():
    print """ This code can be used to transform DFF input file into GULP input file
usage: dff2gulp ppffile msdfile"""
    
if __name__ == "__main__":

    

    if len(sys.argv) < 3:
        usage()
    else:
        ppf_file = sys.argv[1]
        msd_file = sys.argv[2]
    if len(sys.argv) > 3 and int(sys.argv[3]) == 1:
        fit = sys.argv[3]
        keywords = ["fit", "minim", "molmec", "nomod", "noauto"]
    else:
        fit = 0
        keywords = ["opti", "conp", "prop", "phon", "inten", "minim", "molmec", "nomod", "noauto"]
        options = ["pressure 0 GPa"]

    eqt_table_fftype_apptype = msd2gin("%s.gin"%msd_file, "%s.msd"%msd_file, keywords, options, "%s.lib"%ppf_file, fit)
    ppf2lib(ppf_file, msd_file, eqt_table_fftype_apptype, fit)
    outcontrol(msd_file)

    

    
